<?php
defined('_JEXEC') or die('Restricted access');


class DoskaModelCategories extends JModelList {
	
	public function __construct($config = array())
	{
		
		$config['filter_fields'] = array(
									'id',
									'name',
									'state',
									'ordering'
		
		);
		
		parent::__construct($config);
	}
	
	
	
	protected function getListQuery()
	{
		$db = $this->getDbo();
		$query = $db->getQuery(true);
		
		
		$query->select('id,name,alias,parentid,state,ordering');
		$query->from('#__doska_categories');
		
		/*if($this->getState('cat.state')) {
			$query->where('state = '.$this->getState('cat.state'));
		}*/
		
		$orderCol = $db->escape($this->getState('list.ordering','id'));
		$orderDirn = $db->escape($this->getState('list.direction','desc'));
		
		//ORDER BY id DESC
		$query->order($orderCol. ' '. $orderDirn);
		
		
		
		//echo $query;
		
		return $query;
	}
	
	protected function populateState($ordering = null, $direction = null) {
		
		parent::populateState('id','desc');
	}
	
	
}
?>